import request from '@/utils/request'

export function getRoleList(data) {
  return request({
    url: '/union-auth/role/list',
    method: 'post',
    data
  })
}

// 创建 or 修改角色
export function createOrUpdate(data) {
  return request({
    url: '/union-auth/role/createOrUpdate',
    method: 'post',
    data
  })
}

export function deleteRole(id) {
  return request({
    url: '/union-auth/role/' + id,
    method: 'delete'
  })
}

// 获取角色关联的app列表
export function getAppListByRole(roleId) {
  return request({
    url: '/union-auth/role/getAppListByRole',
    method: 'get',
    params: { roleId }
  })
}

// 根据appName从redis中查找 完全版的路由列表
export function getRouterByAppName(appName) {
  return request({
    url: '/union-auth/role/getRouterByAppName',
    method: 'get',
    params: { appName }
  })
}

// 根据roleId, appId获取permissionCode列表
export function getPermissionListByRole(roleId, appName) {
  return request({
    url: '/union-auth/role/getPermissionListByRole',
    method: 'get',
    params: { roleId, appName }
  })
}

// 修改角色的菜单以及按钮权限
export function confirmAssignPermission(data) {
  return request({
    url: '/union-auth/role/confirmAssignPermission',
    method: 'post',
    data
  })
}
